package com.itrencai.d13_thread.threadpoor;

import java.lang.ref.SoftReference;
import java.util.concurrent.*;

//自定义一个线程池对象并测试其特性
public class ThreadPoorDemo2 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //1.创建线程池对象
/*        public ThreadPoolExecutor( int corePoolSize,核心线程数量
                                     int maximumPoolSize,最大线程数量
                                     long keepAliveTime,最大时间
                                     TimeUnit unit,
                                     BlockingQueue<Runnable> workQueue,
                                     ThreadFactory threadFactory,
                                     RejectedExecutionHandler handler)*/
        ExecutorService pool=new ThreadPoolExecutor(3,5,
                6,TimeUnit.SECONDS,new ArrayBlockingQueue<>(5),Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());

        //2.给任务线程池处理
        Future<String> f1= pool.submit(new MyCallable(100));
        Future<String> f2= pool.submit(new MyCallable(200));
        Future<String> f3= pool.submit(new MyCallable(300));
        Future<String> f4= pool.submit(new MyCallable(400));
        Future<String> f5= pool.submit(new MyCallable(400));

        String rs=f1.get();
        System.out.println(rs);

        System.out.println(f1.get());
        System.out.println(f2.get());
        System.out.println(f3.get());
        System.out.println(f4.get());
        System.out.println(f5.get());

    }
}
